<?php

/**
 * Renders an HTML view using smarty.
 *
 * @author Niels Janssen
 * @since 2009-04-20
 */
class HTMLView extends View
{
	/**
	 * The template file this view belongs to.
	 *
	 * @var string
	 */
	private $templateFile = '';
	
	/**
	 * The smarty object used to render this view.
	 *
	 * @var Smarty
	 */
	private $smarty = null;
	
	
	/**
	 * Constructs the HTMLView object, sets up basic parameters.
	 *
	 * @param string $templateFile
	 * @param Smarty $smarty
	 */
	function __construct( $templateFile, Smarty $smarty )
	{
		$this->templateFile = substr( $templateFile, -4 ) == '.tpl' ? $templateFile : $templateFile . '.tpl';
		$this->smarty = $smarty;
	}
	
	/**
	 * @see View::render()
	 *
	 */
	public function render()
	{
		return $this->smarty->fetch( $this->templateFile );
	}
	
	/**
	 * @see View::assign()
	 *
	 */
	public function assign( $key, $value )
	{
		$this->smarty->assign( $key, $value );
	}
	
	/**
	 * @see View::assignArray()
	 *
	 */
	public function assignArray( array $array )
	{
		$this->smarty->assign( $array );
	}
	
	public function __toString()
	{
		return $this->render();
	}
}